<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue-router</title>
  </head>
  <body>
    <div class="" id="app">
      <router-link to="/test">Model</router-link>
      <router-view></router-view>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script src="../node_modules/vue-router/dist/vue-router.js"></script>
    <script>
      //   路由组件
      var testModel = {
        template: `
            <div>
                <h1>Model</h1>
                <hr/>
                <router-link to="/test/test2">Model2</router-link>
                <router-view></router-view>
                </div>
            `,
      }
      const testModel2 = {
        template: `
          <div>这是Model2</div>
          `,
      }
      // 路由规则创建
      var luyou = new VueRouter({
        routes: [
          {
            path: '/test',
            component: testModel,
            children: [{ path: 'test2', component: testModel2 }],
          },
        ],
      })
      var vm = new Vue({
        el: '#app',
        data: {},
        router: luyou,
      })
    </script>
  </body>
</html>
